﻿using B.MES.Customer.Application.IApplication;
using B.MES.Customer.Domain;
using B.MES.Customer.Domain.DTO;
using B.MES.Customer.Infrastructure.IRepository;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Yitter.IdGenerator;

namespace B.MES.Customer.Application.Application
{
    /// <summary>
    /// 生产服务实现层
    /// </summary>
    public class ProduceApplication : BaseApplication<Produce>, IProduceApplication
    {
        private readonly IProduceRepository _produceRepository;
        public ProduceApplication(IProduceRepository produceRepository) : base(produceRepository)
        {
            _produceRepository = produceRepository;
        }


        /// <summary>
        /// 新增生产
        /// </summary>
        /// <param name="produce">需要添加的生产数据</param>
        /// <returns>受影响行数</returns>
        public int AddProduce(Produce produce, string? SalesOrderNumber)
        {
            return _produceRepository.AddProduce(produce, SalesOrderNumber);
        }

        /// <summary>
        /// 生产的显示分页查询
        /// </summary>
        /// <param name="ProCode">生产单号</param>
        /// <param name="pageIndex">当前是第几页</param>
        /// <param name="pageSize">每页需要显示多少条数据</param>
        /// <returns>生产的查询显示分页</returns>
        public PageApiResut<Produce> GetProduceShow(string? ProCode, int pageIndex, int pageSize)
        {
            return _produceRepository.GetProduceShow(ProCode, pageIndex, pageSize);
        }
        /// <summary>
        /// 获取生产信息
        /// </summary>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public List<Produce> GetProduct()
        {
            var result=_produceRepository.GetProduct();
            return result;
        }

        /// <summary>
        /// 删除生产信息
        /// </summary>
        /// <param name="ProId">ID</param>
        /// <returns>受影响行数</returns>
        public int DelteProduce(int ProId)
        {
            var result = _produceRepository.DelteProduce(ProId);
            return result;
        }

        /// <summary>
        /// 更新生产信息
        /// </summary>
        /// <param name="produce">需要更新的生产信息</param>
        /// <returns>受影响行数</returns>
        public int UpdateProduce(Produce produce)
        {
            var result = _produceRepository.UpdateProduce(produce);
            return result;
        }

        /// <summary>
        /// 根据生产Id获取生产信息
        /// </summary>
        /// <param name="ProId">生产Id</param>
        /// <returns>生产信息</returns>
        /// <exception cref="NotImplementedException"></exception>
        public Produce GetProduceByProId(int ProId)
        {
            var result = _produceRepository.GetProduceByProId(ProId);
            return result;
        }
    }
}
